// +build go1.13

// Copyright (c) 2015-2021 Jeevanandam M (jeeva@myjeeva.com), All rights reserved.
// mamba source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.

package mamba

import (
	http "github.com/Danny-Dasilva/fhttp"
	"net"
	"runtime"
	"time"
)

func CreateRoundTripper(ja3, ua string) http.RoundTripper {
	//dialer, _ := newConnectDialer("http://192.168.31.54:8888", ua)
	//lAddr, _ := net.ResolveTCPAddr("www.amazon.com", "192.168.31.54")
	//fmt.Println(lAddr)
	dialer := &net.Dialer{
		Timeout:   30 * time.Second,
		KeepAlive: 30 * time.Second,
		DualStack: true,
	}
	return newRoundTripper(ja3, ua, dialer)
	//return newRoundTripper(ja3, ua, proxy.Direct)

}

func createTransport(localAddr net.Addr) *http.Transport {
	dialer := &net.Dialer{
		Timeout:   30 * time.Second,
		KeepAlive: 30 * time.Second,
		DualStack: true,
	}
	if localAddr != nil {
		dialer.LocalAddr = localAddr
	}

	return &http.Transport{
		Proxy:                 http.ProxyFromEnvironment,
		DialContext:           dialer.DialContext,
		ForceAttemptHTTP2:     false,
		MaxIdleConns:          100,
		IdleConnTimeout:       90 * time.Second,
		TLSHandshakeTimeout:   10 * time.Second,
		ExpectContinueTimeout: 1 * time.Second,
		MaxIdleConnsPerHost:   runtime.GOMAXPROCS(0) + 1,
	}
}
